package cn.jingyuan.swan.gw;

import cn.jingyuan.swan.gw.locator.RemoteRouteLocator;
import cn.jingyuan.swan.gw.locator.ResourceLocator;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.cloud.openfeign.EnableFeignClients;

import javax.annotation.Resource;


@EnableFeignClients
@EnableDiscoveryClient
@EnableZuulProxy

@SpringBootApplication
public class GatewayServer implements CommandLineRunner {

    @Resource
    RemoteRouteLocator routeLocator;

    @Resource
    ResourceLocator resourceLocator;

    public static void main(String[] args) {
        SpringApplication.run(GatewayServer.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        routeLocator.doRefresh();
        resourceLocator.doRefresh();
    }

}

